Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-use base image's entrypoint, refactor bootstrap script #970

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

carlzogh
Copy link
Contributor

@carlzogh carlzogh commented Nov 11, 2021

Description of changes:

1. Refactor net5 and net6 bootstrap scripts to /var/runtime/bootstrap

This is in order to make use of the provided image's bundled /lambda-entrypoint.sh entrypoint. The script also handles deciding whether or not the bootstrap should run through the RIE.

This is what /lambda-entrypoint.sh looks like:

#!/bin/sh
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

if [ $# -ne 1 ]; then
  echo "entrypoint requires the handler name to be the first argument" 1>&2
  exit 142
fi
export _HANDLER="$1"

RUNTIME_ENTRYPOINT=/var/runtime/bootstrap
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
  exec /usr/local/bin/aws-lambda-rie $RUNTIME_ENTRYPOINT
else
  exec $RUNTIME_ENTRYPOINT
fi

2. Allow handler to be specified with _HANDLER

_HANDLER will be used if the first command-line argument is not specified. This is to support running through /lambda-entrypoint.sh which does not pass the handler string in as a command-line argument, but as an environment variable.

3. Add support for exec wrapper scripts

ref. https://docs.aws.amazon.com/lambda/latest/dg/runtimes-modify.html#runtime-wrapper

This is controlled by users through the AWS_LAMBDA_EXEC_WRAPPER environment variable in order to hook into the runtime's start command line arguments.


Testing

Built base images locally (tagged as dotnet5 and dotnet6) and used those in Lambda container image functions:

# intermediate build stages omitted
FROM dotnet5

COPY --from=build-image /build/build_artifacts/ /var/task/

CMD ["HelloWorld::HelloWorld.Function::FunctionHandler"]

And invoked successfully both locally and in the cloud.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@normj normj merged commit a6b6d09 into aws:master Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants